package com.ruoyi.common.utils.uuid;

import com.ruoyi.common.utils.ShortUrlUtils;

/**
 * 生成CODE
 * Updated by gaolianli on 2022/1/9.
 */
public class IdFactory {

    private static final SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
    @Deprecated
    public static Long getNewId(){
        LongId id = new LongId();
        return id.toLong();
    }

    public static Long newLongId(){
        return getSnowflakeId();
    }

    public static Long getSnowflakeId(){
        return idWorker.nextId();
    }

    /**
     * 使用,32位UUID
     * @return
     */
    public static String genCode(){
        return IdUtils.fastSimpleUUID();
    }

    //==============================Test=============================================
    /** 测试 */
    public static void main(String[] args) throws InterruptedException {


      /*  for (int i = 0; i < 100; i++) {
            new Thread(()->{
                long id = getSnowflakeId();
                //System.out.println(Long.toBinaryString(id));
                System.out.println(id);
            }).start();

            long id = IdFactory.getSnowflakeId();
            //System.out.println(Long.toBinaryString(id));
            System.out.println(id);
        }
        //Thread.sleep(100000);

        C.println(IdUtils.fastSimpleUUID());
        C.println(IdUtils.fastUUID());
        C.println(IdUtils.randomUUID());
        C.println(IdUtils.simpleUUID());
        IdFactory.getSnowflakeId();
        C.println(IdFactory.genCode());
        IdFactory.genShortCode();
        C.println(IdFactory.genShortCode("22fff"));
*/

//        C.println("LX" + DateUtils.dateTimeNow() + "-" + ShortUrlUtils.ShortTextOne() + "-" + IdFactory.genShortCode());
//        Date d1 = DateUtils.parseDate("2025-12-13 05:25:25");
//        System.out.println(d1.getTime());
//        System.out.println(System.currentTimeMillis());
//        Date d2 = DateUtils.parseDate("2023-12-13 05:25:25");
//        System.out.println(d2.getTime());
    }

}
